import { defineStore } from 'pinia'
import {ref,computed} from "vue";

//定义一个 money存储单元
export const useMoneyStore
    = defineStore('money', () => {

    const salary = ref(1000); // ref() 就是 state 属性
    const dollar = computed(() => salary.value * 0.5); //  computed() 就是 getters

    //function() 就是 actions
    const pay = () => {
        salary.value -= 100;
    }
    const win = () => {
        salary.value += 1000;
    }
    //重要：返回可用对象
    return {salary,dollar,pay,win}
})